import 'package:flutter/material.dart';
import 'package:flutter_shop/pages/home/goods_detail/entity/goods_detail_data.dart';
import 'package:flutter_shop/res/colors.dart';
import 'package:flutter_shop/res/dimens.dart';
import 'package:flutter_shop/res/styles.dart';
import 'package:flutter_shop/widget/load_image.dart';

///顶部商品信息
class TopGoodsInfo extends StatelessWidget {
  ///控件的高度
  static final double height = 400.0 + 40 + 20 + 30 + 50 + 10 + 40 + 10;

  final GoodsDetailDataGoodInfo goodInfo;

  TopGoodsInfo({Key key, this.goodInfo}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          _buildImage(),
          _buildTitle(),
          _buildExtra(),
          _buildNumber(),
          _buildPrice(),
          Container(color: CommonColors.common_bg, height: 10),
          _buildDes(),
          Container(color: CommonColors.common_bg, height: 10),
        ],
      ),
    );
  }

  ///图片 400
  Widget _buildImage() {
    return LoadImage(goodInfo.image1, width: double.infinity, height: 400, fit: BoxFit.cover);
  }

  ///标题 40
  Widget _buildTitle() {
    return Container(
      alignment: Alignment.centerLeft,
      height: 40,
      padding: Paddings.left_right,
      child: Text(goodInfo.goodsName, style: TextStyles.common_title_text),
    );
  }

  ///Extra 20
  Widget _buildExtra() {
    return Container(
      height: 20,
      padding: EdgeInsets.symmetric(horizontal: 5),
      margin: EdgeInsets.only(left: 15),
      decoration: BoxDecoration(
        border: Border(
          top: BorderSide(color: CommonColors.green),
          right: BorderSide(color: CommonColors.green),
          bottom: BorderSide(color: CommonColors.green),
          left: BorderSide(color: CommonColors.green),
        ),
      ),
      child: Text("支持配送到家", style: TextStyle(color: CommonColors.green, fontSize: CommonDimens.font_size_small)),
    );
  }

  ///编号 30
  Widget _buildNumber() {
    return Container(
      alignment: Alignment.centerLeft,
      height: 30,
      padding: Paddings.left_right,
      child: Text("编号:${goodInfo.goodsSerialNumber}", style: TextStyles.second_text),
    );
  }

  ///价格 50
  Widget _buildPrice() {
    return Container(
      alignment: Alignment.centerLeft,
      height: 50,
      padding: Paddings.left_right,
      child: Row(
        children: <Widget>[
          Text("¥${goodInfo.presentPrice}",
              style: TextStyle(
                fontSize: CommonDimens.font_size_xlarge,
                color: CommonColors.red,
              )),
          Gaps.h_gap_15,
          Text(
            "市场价:",
            style: TextStyle(
              fontSize: CommonDimens.font_size_middle,
              color: CommonColors.common_text,
            ),
          ),
          Gaps.h_gap_10,
          Text(
            "¥${goodInfo.oriPrice}",
            style: TextStyle(
              fontSize: CommonDimens.font_size_middle,
              color: CommonColors.gray,
              decoration: TextDecoration.lineThrough,
            ),
          ),
        ],
      ),
    );
  }

  ///说明 40
  Widget _buildDes() {
    return Container(
      alignment: Alignment.centerLeft,
      height: 40,
      padding: Paddings.left_right,
      child: Text("说明:>急速送达>正品保证", style: TextStyle(color: CommonColors.red, fontSize: CommonDimens.font_size_middle)),
    );
  }
}
